Sorry, your browser cannot access this site
This page requires browser support (enable) JavaScript
Learn more >

MengFanjun的博客

一、电路接线

霍尔传感器引脚 Arduino引脚
VCC 5V
GND GND
D0 7
A0 A0

二、程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#define Moisture A0
#define D0 7
void setup() {
pinMode(Moisture,INPUT);
pinMode(D0,INPUT);
Serial.begin(9600);

}

void loop() {
Serial.print("Moisture=");//湿度
Serial.print(analogRead(Moisture));
Serial.print("|D0=");
Serial.println(digitalRead(D0));
delay(1000);
}

三、效果

在这里插入图片描述

评论